home *** CD-ROM | disk | FTP | other *** search
-
- regc( 0, "TFACTOR" )
- regc4f( 3, %dirtcolor_r, %dirtcolor_g, %dirtcolor_b, %sunvisibility )
- regc4f( 4, %dirtsnow, %dirtgravel, %dirtmud, 0.0 )
- regc4f( 5, %daycolor_r, %daycolor_g, %daycolor_b, %daycolor_a )
- regc4f( 7, %ambient_r, %ambient_g, %ambient_b, %ambient_a )
-
- hlsl("
- #include <../common_hlsl.h>
- #include <cardef.h>
-
- sampler2D sColor: register(s0);
- sampler2D sDirt: register(s1);
- sampler2D sClouds: register(s2);
- sampler2D sLightmap: register(s3);
- samplerCUBE sCubemap: register(s4);
- sampler2D sDirtNormalmap: register(s5);
-
- const HALF4 DirtLevel : register(c0); // DirtLevel.a
- const HALF4 DirtColor_Sun : register(c3);
- const HALF3 DirtType : register(c4);
- const HALF3 DayColor : register(c5);
- const HALF4 Ambient : register(c7);
-
- static const HALF3 Tiling = {SNOWTILING, GRAVELTILING, MUDTILING};
- static const HALF3 FlatNormal = {0.0f, 0.0f, 1.0f};
-
- struct PS_INPUT
- {
- HALF SpotDiffuse: COLOR0;
- HALF2 uvColor : TEXCOORD0;
- float3 L : TEXCOORD1;
- float3 R_ts : TEXCOORD2;
- float3 R_ws: TEXCOORD3;
- HALF2 Fresnel_and_Weight: TEXCOORD4;
- HALF2 uvClouds: TEXCOORD5;
- HALF2 uvLightmap: TEXCOORD6;
- };
-
- HALF4 main( PS_INPUT i ): COLOR {
-
- HALF Fresnel = i.Fresnel_and_Weight.x;
- HALF DamageLevel = i.Fresnel_and_Weight.y;
- HALF4 DirtScratch = tex2D( sDirt, i.uvColor );
- HALF Scratch = DirtScratch.a*DamageLevel;
- HALF3 DirtColor = DirtColor_Sun.rgb;
- HALF SunVisibility = DirtColor_Sun.a;
-
- HALF DirtMask = saturate(dot(DirtScratch.rgb, DirtType)*DirtLevel.a - Scratch);
- HALF3 DirtNormalmapTiling = dot(DirtType, Tiling);
- HALF3 Normalmap = tex2D( sDirtNormalmap, i.uvColor*DirtNormalmapTiling )*2 - 1;
- Normalmap = lerp( FlatNormal, Normalmap, DirtMask);
- HALF Diffuse = diffuse( Normalmap, i.L);
- HALF Specular = phong(i.R_ts, i.L, SPECULARPOW)*SunVisibility;
- HALF3 Cubemap = texCUBE( sCubemap, i.R_ws);
-
- HALF Clouds = 1-(tex2D(sClouds, i.uvClouds)).a;
- HALF Lightmap = saturate((tex2D(sLightmap, i.uvLightmap)).a);
- HALF Shadows = saturate(Clouds*Lightmap*SHADOWSMUL+SOFTSHADOWS);
-
- Diffuse = saturate(Ambient.r*Shadows*Diffuse + Ambient.a);
-
- HALF4 Color = tex2D( sColor, i.uvColor );
-
- HALF CubemapMask = saturate(Color.a*2-1);
- HALF SpecularMask = saturate(Color.a*2);
- CubemapMask = saturate(CubemapMask+Fresnel*CubemapMask*16-Scratch);
- CubemapMask *= 1-DirtMask;
- SpecularMask *=(1-DirtMask)*Shadows;
-
- Color.rgb = lerp( Color, DirtColor, DirtMask);
- Color.rgb = lerp( Color, SCRATCHCOLOR, Scratch);
-
- #if VS_SPOTLIGHTS
- HALF3 Spot = Color.rgb*i.SpotDiffuse;
- #endif
-
- Color.rgb = saturate(Color*Diffuse+Specular*SpecularMask+Cubemap*CubemapMask)*DayColor;
-
- #if VS_SPOTLIGHTS
- Color.rgb = saturate(Color+Spot);
- #endif
- Color.a = WATERDEEP; // water
- return Color;
- }
- ")
-
-